/**  
 * @description 文件上传  
 * @param data 文件路径  
 * @param uuid 文件uuid  
 * @param progressCallBack 上传进度回调  
 */
function uploadFile(data, uuid, progressCallBack) {
	var promise = new Promise((resolve, reject) => {
		var tempFilePaths = data;
		const uploadTask = uni.uploadFile({
			url: "http://121.36.26.224:9101/CustomerManagement/SalesmanDailyRecord/UploadFileByForm", //仅为示例，非真实的接口地址
			filePath: tempFilePaths,
			name: 'file',
			header: {
				'Authorization': 'Bearer ' + uni.getStorageSync('token')
			},
			success: async (res) => {

				console.log(res)
				// 获取图片list  
				const {
					data,
					statusCode
				} = res

				if (statusCode == 200) {
					resolve({
						url: data,
						uuid
					})
				}
			},
			fail: (res) => {
				reject(res);
			}
		});
		// 通过uploadTask 监听上传进度   
		uploadTask.onProgressUpdate(res => {
			progressCallBack(res)
		})
	});
	return promise;
}

export default {
	uploadFile
}